const express = require('express')
const app = express();

const vipLogin = require("./data/vip_login.json")
const adminLogin = require("./data/admin_login.json")
const vipPermission = require("./data/vip_permission.json")
const adminPermission = require("./data/admin_permission.json")
const userInfo = require("./data/userInfo.json")
const logout = require("./data/logoutdata.json")
const url = require("url")

app.get("/login",(req,res)=>{
  const user = url.parse(req.url,true).query.user;
  if(user === 'wangwu'){
    res.send(adminLogin)
  }else{
    res.send(vipLogin)
  }
})
app.get("/catalogue",(req,res)=>{
  const user = url.parse(req.url,true).query.user;
  if(user === 'wangwu'){
    res.send(adminPermission)
  }else{
    res.send(vipPermission)
  }
})
app.get("/userInfo",(req,res)=>{
  const user = url.parse(req.url,true).query.user;
  if(user === 'wangwu'){
    res.send(userInfo)
  }
})
app.post("/logout",(req,res)=>{
    res.send(logout)
})
app.listen(3300,()=>{
  console.log("服务器搁3300运行呢")
})